package com.uhu.code;

/**
 * 53. 最大子数组和
 * https://leetcode.cn/problems/maximum-subarray/description/?envType=study-plan-v2&envId=top-100-liked
 */
public class Solution53 {
    public int maxSubArray(int[] nums) {
        int max = nums[0];
        for (int i = 0; i < nums.length; i++) {
            int count = nums[i];
            int k = i + 1;
            while (k < nums.length) {
                count = count + nums[k];
                max = max > count ? max : count;
                k++;
            }
        }
        return max;
    }
}
